#include "Base.h"
#include "BaseProtocol.h"
#include "MLprotocol.h"

BOOL MLAddProductMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	iStream.Read((char*)&m_nProductType, sizeof(m_nProductType));
	iStream.Read((char*)&m_dwGameId, sizeof(m_dwGameId));
	iStream.Read((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	iStream.Read((char*)&m_nUnitType, sizeof(m_nUnitType));
	iStream.Read((char*)&m_dwMisIP, sizeof(m_dwMisIP));
	iStream.Read((char*)&m_nMisPort, sizeof(m_nMisPort));
  	m_stSignCost.Read(iStream);
	iStream.Read((char*)&m_nSignupPlayerCount, sizeof(m_nSignupPlayerCount));
	return TRUE;
}

BOOL MLAddProductMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	oStream.Write((char*)&m_nProductType, sizeof(m_nProductType));
	oStream.Write((char*)&m_dwGameId, sizeof(m_dwGameId));
	oStream.Write((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	oStream.Write((char*)&m_nUnitType, sizeof(m_nUnitType));
	oStream.Write((char*)&m_dwMisIP, sizeof(m_dwMisIP));
	oStream.Write((char*)&m_nMisPort, sizeof(m_nMisPort));
	m_stSignCost.Write(oStream);
	oStream.Write((char*)&m_nSignupPlayerCount, sizeof(m_nSignupPlayerCount));
	return TRUE;
}

BOOL MLUpdateProductMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwGameId, sizeof(m_dwGameId));
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	iStream.Read((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	iStream.Read((char*)&m_nSignupPlayer, sizeof(m_nSignupPlayer));
	iStream.Read((char*)&m_nStatus, sizeof(m_nStatus));
	return TRUE;
}

BOOL MLUpdateProductMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwGameId, sizeof(m_dwGameId));
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	oStream.Write((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	oStream.Write((char*)&m_nSignupPlayer, sizeof(m_nSignupPlayer));
	oStream.Write((char*)&m_nStatus, sizeof(m_nStatus));
	return TRUE;
}

BOOL MLDelProductMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwGameId, sizeof(m_dwGameId));
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	return TRUE;
}

BOOL MLDelProductMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwGameId, sizeof(m_dwGameId));
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	return TRUE;
}

BOOL LMSignupMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwClientId, sizeof(m_dwClientId));
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	iStream.Read((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	iStream.Read((char*)&m_szUserName, sizeof(m_szUserName));
	iStream.Read((char*)&m_dwSignupIP, sizeof(m_dwSignupIP));
	iStream.Read((char*)&m_nFigure, sizeof(m_nFigure));
	return TRUE;
}

BOOL LMSignupMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwClientId, sizeof(m_dwClientId));
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	oStream.Write((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	oStream.Write((char*)&m_szUserName, sizeof(m_szUserName));
	oStream.Write((char*)&m_dwSignupIP, sizeof(m_dwSignupIP));
	oStream.Write((char*)&m_nFigure, sizeof(m_nFigure));
	return TRUE;
}

BOOL MLSignupMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwClientId, sizeof(m_dwClientId));
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	iStream.Read((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	iStream.Read((char*)&m_nResult, sizeof(m_nResult));
	iStream.Read((char*)&m_szResult, sizeof(m_szResult));
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	iStream.Read((char*)&m_nSignupPlayerCount, sizeof(m_nSignupPlayerCount));
	return TRUE;
}

BOOL MLSignupMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwClientId, sizeof(m_dwClientId));
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	oStream.Write((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	oStream.Write((char*)&m_nResult, sizeof(m_nResult));
	oStream.Write((char*)&m_szResult, sizeof(m_szResult));
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	oStream.Write((char*)&m_nSignupPlayerCount, sizeof(m_nSignupPlayerCount));
	return TRUE;
}

BOOL LMSignoffMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwClientId, sizeof(m_dwClientId));
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	iStream.Read((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	return TRUE;
}

BOOL LMSignoffMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwClientId, sizeof(m_dwClientId));
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	oStream.Write((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	return TRUE;
}

BOOL MLSignoffMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwClientId, sizeof(m_dwClientId));
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	iStream.Read((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	iStream.Read((char*)&m_nResult, sizeof(m_nResult));
	iStream.Read((char*)&m_szResult, sizeof(m_szResult));
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	iStream.Read((char*)&m_nSignupPlayerCount, sizeof(m_nSignupPlayerCount));
	return TRUE;
}

BOOL MLSignoffMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwClientId, sizeof(m_dwClientId));
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	oStream.Write((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	oStream.Write((char*)&m_nResult, sizeof(m_nResult));
	oStream.Write((char*)&m_szResult, sizeof(m_szResult));
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	oStream.Write((char*)&m_nSignupPlayerCount, sizeof(m_nSignupPlayerCount));
	return TRUE;
}

BOOL MLStartMatchMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	iStream.Read((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	iStream.Read((char*)&m_dwGameId, sizeof(m_dwGameId));
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	iStream.Read((char*)&m_dwMatchId, sizeof(m_dwMatchId));
	iStream.Read((char*)&m_szGsIP, sizeof(m_szGsIP));
	iStream.Read((char*)&m_nPort, sizeof(m_nPort));
	return TRUE;
}

BOOL MLStartMatchMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	oStream.Write((char*)&m_tmMatchStartTime, sizeof(m_tmMatchStartTime));
	oStream.Write((char*)&m_dwGameId, sizeof(m_dwGameId));
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	oStream.Write((char*)&m_dwMatchId, sizeof(m_dwMatchId));
	oStream.Write((char*)&m_szGsIP, sizeof(m_szGsIP));
	oStream.Write((char*)&m_nPort, sizeof(m_nPort));
	return TRUE;
}

BOOL MLPlayerBreakMsg::Read( CSocketStream& iStream )
{
	iStream.Read((char*)&m_dwProductId, sizeof(m_dwProductId));
	iStream.Read((char*)&m_dwGameId, sizeof(m_dwGameId));
	iStream.Read((char*)&m_dwUserId, sizeof(m_dwUserId));
	iStream.Read((char*)&m_dwMatchId, sizeof(m_dwMatchId));
	iStream.Read((char*)&m_dwTableId, sizeof(m_dwTableId));
	iStream.Read((char*)&m_szGsIP, sizeof(m_szGsIP));
	iStream.Read((char*)&m_nPort, sizeof(m_nPort));
	return TRUE;
}

BOOL MLPlayerBreakMsg::Write( CSocketStream& oStream ) const
{
	oStream.Write((char*)&m_dwProductId, sizeof(m_dwProductId));
	oStream.Write((char*)&m_dwGameId, sizeof(m_dwGameId));
	oStream.Write((char*)&m_dwUserId, sizeof(m_dwUserId));
	oStream.Write((char*)&m_dwMatchId, sizeof(m_dwMatchId));
	oStream.Write((char*)&m_dwTableId, sizeof(m_dwTableId));
	oStream.Write((char*)&m_szGsIP, sizeof(m_szGsIP));
	oStream.Write((char*)&m_nPort, sizeof(m_nPort));
	return TRUE;
}


